package com.richfit.barcodesystem_cczt.fragments;

import android.app.Dialog;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.GridView;
import android.widget.LinearLayout;
import android.widget.TextView;

import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.bigkoo.alertview.AlertView;
import com.google.android.material.tabs.TabLayout;
import com.richfit.barcodesystem_cczt.R;
import com.richfit.barcodesystem_cczt.activitis.Main;
import com.richfit.barcodesystem_cczt.activitis.adapters.BottomDialogMenuAdapter;
import com.richfit.barcodesystem_cczt.activitis.model.base.Result;
import com.richfit.barcodesystem_cczt.activitis.model.login.BottomMenuEntity;
import com.richfit.barcodesystem_cczt.databinding.FragmentBatchCheckOutBinding;
import com.richfit.barcodesystem_cczt.databinding.LayoutCheckoutItemBinding;
import com.richfit.barcodesystem_cczt.fragments.adapters.BatchCheckOut_Detail_Adapter;
import com.richfit.barcodesystem_cczt.fragments.base.BaseFragment;
import com.richfit.barcodesystem_cczt.fragments.model.ZBoxEntity;
import com.richfit.barcodesystem_cczt.network.OkHttpUtils;
import com.richfit.barcodesystem_cczt.utils.Urls;
import com.richfit.barcodesystem_cczt.utils.constant.CCZT_BizConfig;
import com.richfit.barcodesystem_cczt.utils.dialog.DialogHelper;
import com.richfit.barcodesystem_cczt.utils.toast.ToastUtil;
import com.richfit.barcodesystem_cczt.widget.RichAutoEditText;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;

/**
 * A simple {@link Fragment} subclass.
 * Use the {@link BatchCheckOut} factory method to
 * create an instance of this fragment.
 */
public class BatchCheckOut extends BaseFragment {
    private static final String TAG = "BatchCheckOut";
    private FragmentBatchCheckOutBinding binding;
    private String bizType;
    private BatchCheckOut_Detail_Adapter adapter;
    /**
     * 分箱单明细
     */
    private Map<String, ZBoxEntity.FBox> fBoxMap = new HashMap<>();
    /**
     * 当前选中的item项，默认为0;
     */
    private int detailItemIndex = -1;
    /**
     * 当前选中的分箱单号
     */
    private String detailBoxNum = "";
    /**
     * 控制箱号采集，是否可以进行保存
     * 批量出库操作可以进行分箱单中的箱子调整
     */
    private Boolean collectionIsSave = false;

    public BatchCheckOut(String bizType) {
        this.bizType = bizType;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        binding = FragmentBatchCheckOutBinding.inflate(inflater, container, false);
        initView();
        initData();

        return binding.getRoot();
    }

    private void initView() {
        //TabLayout 定在第一项
        binding.tabLayoutTitle.getTabAt(0).select();
        //初始化 三个页面的显示&隐藏
        binding.icdHead.getRoot().setVisibility(View.VISIBLE);
        binding.icdDetail.getRoot().setVisibility(View.GONE);
        binding.icdCollection.getRoot().setVisibility(View.GONE);
        //清空分箱单号数据
        binding.icdHead.EdtZBoxNum.setText("");
        //再次获取焦点
        binding.icdHead.EdtZBoxNum.setFocusable(true);
        binding.icdHead.EdtZBoxNum.setFocusableInTouchMode(true);
        binding.icdHead.EdtZBoxNum.requestFocus();
        //批量出库 采集页面显示操作按钮
        //批量出库操作可以进行分箱单中的箱子调整
        if (bizType.equals(CCZT_BizConfig.WZCK)) {
            binding.icdCollection.floatingButton.setVisibility(View.VISIBLE);
            binding.icdCollection.LLSourceFboxNum.setVisibility(View.VISIBLE);
            binding.icdCollection.LLTargetFboxNum.setVisibility(View.VISIBLE);
        } else {
            binding.icdCollection.floatingButton.setVisibility(View.GONE);
            binding.icdCollection.LLSourceFboxNum.setVisibility(View.GONE);
            binding.icdCollection.LLTargetFboxNum.setVisibility(View.GONE);
        }
        setRefCount(0);
    }

    /**
     * 显示当前扫描的分箱单数量
     *
     * @param tvRefCount
     */
    void setRefCount(int tvRefCount) {
        binding.icdHead.tvRefCount.setText(String.format(Locale.CHINA, "分箱单数量 : %d", tvRefCount));
    }

    private void initData() {
        binding.tabLayoutTitle.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
            @Override
            public void onTabSelected(TabLayout.Tab tab) {
                int selectTab = tab.getPosition();
                if (selectTab == -1 || selectTab == 0) {
                    binding.icdHead.getRoot().setVisibility(View.VISIBLE);
                    binding.icdDetail.getRoot().setVisibility(View.GONE);
                    binding.icdCollection.getRoot().setVisibility(View.GONE);
                } else if (selectTab == 1) {
                    binding.icdHead.getRoot().setVisibility(View.GONE);
                    binding.icdDetail.getRoot().setVisibility(View.VISIBLE);
                    binding.icdCollection.getRoot().setVisibility(View.GONE);
                } else if (selectTab == 2) {
                    binding.icdHead.getRoot().setVisibility(View.GONE);
                    binding.icdDetail.getRoot().setVisibility(View.GONE);
                    binding.icdCollection.getRoot().setVisibility(View.VISIBLE);
                }
            }

            @Override
            public void onTabUnselected(TabLayout.Tab tab) {
            }

            @Override
            public void onTabReselected(TabLayout.Tab tab) {
            }
        });
        binding.icdHead.EdtZBoxNum.setOnRichAutoEditTouchListener((view, text) -> {
            getRefData(text);
        });
        /**
         * 按钮点击
         */
        binding.icdDetail.floatingButton.setOnClickListener(v -> showChooseDialog());
        //控件拖动
        setViewMove(binding.icdDetail.floatingButton);
        binding.icdCollection.floatingButton.setOnClickListener(v -> shwoChooseDialogWXCK());
        //控件拖动
        setViewMove(binding.icdCollection.floatingButton);
        //箱号采集
        binding.icdCollection.etBoxNum.setOnRichAutoEditTouchListener((view, text) -> {
            BoxCollection(text);
        });
    }

    @Override
    public void handleBarCodeScanResult(String type, String[] list) {
        if (list != null) {
            //获取当前焦点所在的控件
            View vFocus = this.getActivity().getWindow().getDecorView().findFocus();

            if (vFocus instanceof RichAutoEditText) {
                RichAutoEditText richAutoEditText = (RichAutoEditText) vFocus;
                if (richAutoEditText.getId() == binding.icdHead.EdtZBoxNum.getId()) {
                    //抬头 装箱单
                    binding.icdHead.EdtZBoxNum.setText(list[0]);
                    getRefData(list[0]);
                    binding.icdHead.EdtZBoxNum.setText("");
                } else if (richAutoEditText.getId() == binding.icdCollection.etBoxNum.getId()) {
                    //采集  箱单
                    binding.icdCollection.etBoxNum.setText(list[0]);
                    BoxCollection(list[0]);
                    binding.icdCollection.etBoxNum.setText("");
                }

            }
            ToastUtil.showTextShort(list[0]);
        }
    }

    /**
     * 箱子采集功能
     *
     * @param text
     */
    private void BoxCollection(String text) {
        boolean isChecked = false;
        //当前选中的分单箱
//            for (int i = 0; i < fBoxMap.get(DetailboxNum).getLines().size(); i++) {
//                ZBoxEntity.FBox fBox = fBoxMap.get(DetailboxNum);
//                ZBoxEntity.Line line = fBox.getLines().get(i);
//                //ZboxBarcode 箱号
//                if (text.equals(line.getZboxBarcode())) {
//                    isChecked = true;
//                    if (line.getIsChecked()) {
//                        ToastUtil.showTextShort("已经采集！", binding.getRoot());
//                        break;
//                    }
//                    setItemMove(fBox);
//                    setItemContent(text, i, line);
//                    break;
//                }
//            }
        //在全部分箱单中查找
        //记录是否跳出循环的标签
        Boolean flag = false;
        //要在所有的分单箱中，查找并判断是否采集
        for (String key : fBoxMap.keySet()) {
            if (flag) {
                break;
            }
            ZBoxEntity.FBox fBox = fBoxMap.get(key);

            for (int i = 0; i < fBox.getLines().size(); i++) {
                ZBoxEntity.Line line = fBox.getLines().get(i);
                //ZboxBarcode 箱号
                if (text.equals(line.getZboxBarcode())) {
                    isChecked = true;
                    if (line.getIsChecked()) {
                        //已经选中或采集，直接给出提示，防止重复
                        ToastUtil.showTextShort("已经采集！", binding.getRoot());
                        flag = true;
                        break;
                    }
                    //加载 调整分箱单的数据
                    setItemMove(fBox);
                    //显示箱子详情
                    setItemContent(line);
                    //采集到的项变为绿色
                    fBoxMap.get(key).getLines().get(i).setIsChecked(!fBoxMap.get(key).getLines().get(i).getIsChecked());
                    adapter.notifyDataSetChanged();
                    flag = true;
                    break;
                }
            }
        }
        if (!isChecked) {
            ToastUtil.showTextShort("扫描的箱号不存在分箱单中！", binding.getRoot());
        }
    }

    /**
     * 调整分箱单的箱子到其他分箱单:加载数据
     *
     * @param fBox
     */
    private void setItemMove(ZBoxEntity.FBox fBox) {
        //批量出库操作可以进行分箱单中的箱子调整
        if (bizType.equals(CCZT_BizConfig.WZCK)) {
            //变更操作可保存状态
            collectionIsSave = true;
            //源分箱单
            binding.icdCollection.etSourceFboxNum.setText(fBox.getFboxNum());
            //目标分箱单，加载到下拉框里
            List<String> stringList = new ArrayList<>();
            List<String> idList = new ArrayList<>();

            for (String key : fBoxMap.keySet()) {
                if (!fBox.getFboxNum().equals(key)) {
                    stringList.add(key);
                    idList.add(fBoxMap.get(key).getId());
                }
            }
            setSpinner(binding.icdCollection.SpiTargetFboxNum, stringList, idList);
        }
    }

    /**
     * 填充数据
     *
     * @param line
     */
    private void setItemContent(ZBoxEntity.Line line) {
        //箱子ID
        binding.icdCollection.etBoxNum.setTag(line.getId());
        //箱号清空
        binding.icdCollection.etBoxNum.setText("");
        //箱号显示
        binding.icdCollection.TxtBoxNum.setText(line.getZboxBarcode());
        //装箱单号
        binding.icdCollection.etFboxNum.setText(line.getZboxBarcode().substring(0, line.getZboxBarcode().length() - 4));

        //包装方式
        binding.icdCollection.etPackageManner.setText(line.getPackingSpec());
        //长
        binding.icdCollection.etLength.setText(line.getsLength());
        //宽
        binding.icdCollection.etWidth.setText(line.getsWidth());
        //高
        binding.icdCollection.etHeight.setText(line.getsHeight());
        //体积
        binding.icdCollection.etVolume.setText(line.getsVolume());
        //净重
        binding.icdCollection.etNetWeight.setText(line.getsNetWeight());
        //毛重
        binding.icdCollection.etGrossWeight.setText(line.getsGrossWeight());
        //上架仓位
        binding.icdCollection.etLocation.setText(line.getLocation());

    }

    /**
     * 查询分箱单信息
     *
     * @param boxNum
     */
    private void getRefData(String boxNum) {
        //判断是否重复输入
        for (String key : fBoxMap.keySet()) {
            if (boxNum.equals(key)) {
                ToastUtil.showTextShort(boxNum + ":重复输入！", binding.getRoot());
                return;
            }
        }
        DialogHelper dialogHelper = new DialogHelper(this.getActivity());
        dialogHelper.showLoadingDialog("正在查询装箱单信息");
        OkHttpUtils okHttpUtils = OkHttpUtils.getInstance();
        okHttpUtils.doGet(Urls.URL_FBOX + "?fboxNum=" + boxNum + "&bizType=" + bizType, bo.cookie, new OkHttpUtils.NetCallBack() {

            @Override
            public void onSuccess(Result result) {
                dialogHelper.dismissDialog();
                String data = gson.toJson(result.getData());
                ZBoxEntity.FBox fBox = gson.fromJson(data, ZBoxEntity.FBox.class);
                setItemDetail(boxNum, fBox);
                //分箱单数量
                setRefCount(fBoxMap.size());
                //分箱单列表
                String items = boxNum + "\n" + binding.icdHead.tvRefItems.getText().toString();
                binding.icdHead.tvRefItems.setText(items);
            }

            @Override
            public void onFailure(Exception e) {
                dialogHelper.dismissDialog();
            }
        });
    }


    /**
     * 分箱单明细;添加标题，显示列表
     */
    private void setItemDetail(String boxNum, ZBoxEntity.FBox fBox) {
        binding.icdHead.EdtZBoxNum.setText("");
        //再次获取焦点
        binding.icdHead.EdtZBoxNum.setFocusable(true);
        binding.icdHead.EdtZBoxNum.setFocusableInTouchMode(true);
        binding.icdHead.EdtZBoxNum.requestFocus();
        //记录数据
        fBoxMap.put(boxNum, fBox);
        //一，添加标题
        LinearLayout textView = getTextView(boxNum);
        //设置当前控件为第几项
        textView.setTag(fBoxMap.size() - 1);
        //取消当前选中的项
        if (detailItemIndex != -1) {
            binding.icdDetail.LLItems.getChildAt(detailItemIndex).setBackgroundResource(R.drawable.shape_checkout_item_radius);
        }
        //设置当前项，为选中项目
        detailItemIndex = fBoxMap.size() - 1;
        detailBoxNum = boxNum;

        textView.setOnClickListener(v -> {
            int index = (int) v.getTag();
            if (index == detailItemIndex) {
                //选中当前项，不做处理
            } else {
                binding.icdDetail.LLItems.getChildAt(detailItemIndex).setBackgroundResource(R.drawable.shape_checkout_item_radius);
                detailItemIndex = index;
                detailBoxNum = ((TextView) textView.getChildAt(0)).getText().toString();
                binding.icdDetail.LLItems.getChildAt(detailItemIndex).setBackgroundResource(R.drawable.shape_checkout_item_radius_green);
                //重新加载listView页面
                setDetailList(fBoxMap.get(detailBoxNum));
            }
        });
        binding.icdDetail.LLItems.addView(textView);
        binding.icdDetail.LLItems.getChildAt(detailItemIndex).setBackgroundResource(R.drawable.shape_checkout_item_radius_green);
        setDetailList(fBoxMap.get(detailBoxNum));
    }

    /**
     * 加载listView页面
     *
     * @param fBox
     */
    private void setDetailList(ZBoxEntity.FBox fBox) {
        adapter = new BatchCheckOut_Detail_Adapter(this.getContext(), fBox.getLines());
        GridLayoutManager gridLayoutManager = new GridLayoutManager(this.getContext(), 1, RecyclerView.VERTICAL, false);
        binding.icdDetail.baseDetailRecyclerView.setLayoutManager(gridLayoutManager);
//        binding.baseDetailRecyclerView.addItemDecoration(new DividerGridItemDecoration(this.getContext()));
        binding.icdDetail.baseDetailRecyclerView.setAdapter(adapter);
        // 设置数据后就要给RecyclerView设置点击事件,menusBean:九宫格单项的对象
        adapter.setOnItemClickListener((position, line) -> setOnItemClick(position, line));
        adapter.setOnItemRemoveListener((position, line) -> setOnItemRemove(position, line));

    }

    /**
     * 菜单点击事件
     *
     * @param line
     */
    private void setOnItemClick(int position, ZBoxEntity.Line line) {
        fBoxMap.get(detailBoxNum).getLines().get(position)
                .setIsChecked(!fBoxMap.get(detailBoxNum).getLines().get(position).getIsChecked());
        adapter.notifyDataSetChanged();
    }

    /**
     * Item 删除事件--此事件不符合当前业务要求，需要去掉
     *
     * @param position
     * @param line
     */
    private void setOnItemRemove(int position, ZBoxEntity.Line line) {
        fBoxMap.get(detailBoxNum).getLines().remove(position);
        adapter.notifyDataSetChanged();
        ToastUtil.showTextLong("删除了：" + line.getBoxNo(), binding.getRoot());
    }

    /**
     * 分箱单-Tab页签，显示样式
     *
     * @param text
     * @return
     */
    private LinearLayout getTextView(String text) {
        LayoutCheckoutItemBinding itemBinding = LayoutCheckoutItemBinding.inflate(LayoutInflater.from(this.getContext()));
        itemBinding.TxtTitle.setText(text);
        return itemBinding.getRoot();
    }

    /**
     * 箱号采集-调整分箱单到其他箱子
     * 显示操作保存按钮，弹窗
     */
    private void shwoChooseDialogWXCK() {
        View rootView = LayoutInflater.from(this.getContext()).inflate(R.layout.dialog_bottom_menu, null);
        GridView menu = rootView.findViewById(R.id.gd_menus);
        ArrayList<BottomMenuEntity> items = new ArrayList<>();
        BottomMenuEntity item = new BottomMenuEntity();
        item.setMenuName("保存");
        item.setMenuImageRes(R.mipmap.icon_data_submit);
        items.add(item);
        BottomDialogMenuAdapter adapter = new BottomDialogMenuAdapter(this.getActivity(), items);
        menu.setAdapter(adapter);
        Dialog dialog = setDialog(rootView);
        menu.setOnItemClickListener((parent, view, position, id) -> {
            switch (position) {
                case 0:
                    if (collectionIsSave) {
                        Commit_L();
                    } else {
                        ToastUtil.showTextShort("已经保存，不能再次进行保存。", binding.getRoot());
                    }
                    break;
                default:
                    break;
            }

            dialog.dismiss();
        });
    }

    /**
     * 分箱单明显-过账
     * 显示过账-全选，反选 弹窗
     */
    private void showChooseDialog() {
        View rootView = LayoutInflater.from(this.getContext()).inflate(R.layout.dialog_bottom_menu, null);
        GridView menu = rootView.findViewById(R.id.gd_menus);
        ArrayList<BottomMenuEntity> items = new ArrayList<>();
        BottomMenuEntity item = new BottomMenuEntity();
        item.setMenuName("过账");
        item.setMenuImageRes(R.mipmap.icon_data_submit);
        items.add(item);

        item = new BottomMenuEntity();
        item.setMenuName("全选");
        item.setMenuImageRes(R.mipmap.icon_all_select);
        items.add(item);

        item = new BottomMenuEntity();
        item.setMenuName("反选");
        item.setMenuImageRes(R.mipmap.icon_reverse_select);
        items.add(item);
        BottomDialogMenuAdapter adapter = new BottomDialogMenuAdapter(this.getContext(), items);
        menu.setAdapter(adapter);
        Dialog dialog = setDialog(rootView);
        menu.setOnItemClickListener((adapterView, view, position, id) -> {
            dialog.dismiss();
            switch (position) {
                case 0:
                    //提交
                    Commit_B();
                    break;
                case 1:
                    //全选
                    for (int i = 0; i < fBoxMap.get(detailBoxNum).getLines().size(); i++) {
                        fBoxMap.get(detailBoxNum).getLines().get(i).setIsChecked(true);
                    }
                    setDetailList(fBoxMap.get(detailBoxNum));
                    break;
                case 2:
                    //反选
                    for (int i = 0; i < fBoxMap.get(detailBoxNum).getLines().size(); i++) {
                        fBoxMap.get(detailBoxNum).getLines().get(i).setIsChecked(!fBoxMap.get(detailBoxNum).getLines().get(i).getIsChecked());
                    }
                    setDetailList(fBoxMap.get(detailBoxNum));
                    break;

                default:
                    break;
            }

        });
    }

    AlertView alertView;

    /**
     * 数据提交
     */
    private void Commit_B() {
        List<ZBoxEntity.CommitLine> commit_lines = new ArrayList<>();
        //提示框显示的选中的箱子列表
        String items = "";
        //循环查找所有已选中的项
        for (String key : fBoxMap.keySet()) {
            for (ZBoxEntity.Line line : fBoxMap.get(key).getLines()) {
                if (line.getIsChecked()) {
                    ZBoxEntity.CommitLine commitLine = new ZBoxEntity.CommitLine();
                    commitLine.setFboxLineId(line.getId());
                    commit_lines.add(commitLine);
                    items = items + "\n" + line.getZboxNum() + line.getBoxNo();
                }
            }
        }
        if (commit_lines.size() <= 0) {
            ToastUtil.showTextShort("没有选中任何分箱单！不能进行过账！", binding.getRoot());
            return;
        }
        ZBoxEntity.Commit commit = new ZBoxEntity.Commit();
        commit.setRefLines(commit_lines);


        alertView = new AlertView("提示", "确定提交选中的箱号:" + items, null,
                new String[]{"确定", "取消"}, null, this.getActivity(),
                AlertView.Style.Alert, (o, position1) -> {

            alertView.dismiss();
            if (position1 == 0) {
                BatchOut(commit);
            }
        });
        alertView.show();
    }


    /**
     * 调整分箱单的箱子到其他分箱单
     */
    private void Commit_L() {
        //源分箱单
        String sourceBoxNum = binding.icdCollection.etSourceFboxNum.getText().toString();
        //目标分箱单
        String targetFboxNum = binding.icdCollection.SpiTargetFboxNum.getSelectedItem().toString();
//        //要移动的箱子Num
//        String fboxLineNum = binding.icdCollection.etBoxNum.getText().toString();
        //要移动的箱子ID
        String fboxLineId = binding.icdCollection.etBoxNum.getTag().toString();
        //要移动到目标的分箱单id
        String targetFboxId = binding.icdCollection.SpiTargetFboxNum.getTag().toString();
        DialogHelper dialogHelper = new DialogHelper(this.getActivity());
        dialogHelper.showLoadingDialog("正在提交数据！");
        OkHttpUtils okHttpUtils = OkHttpUtils.getInstance();
        bo.maps = Urls.getDefaultConfigrationMap();
        bo.maps.put("fboxLineId", fboxLineId);
        bo.maps.put("targetFboxId", targetFboxId);

        Log.i(TAG, "Commit_L: " + gson.toJson(bo.maps));

        okHttpUtils.doPostJson(Urls.URL_FBOX_MOVE, bo.cookie, gson.toJson(bo.maps), new OkHttpUtils.NetCallBack() {
            @Override
            public void onSuccess(Result result) {
                dialogHelper.dismissDialog();
//                String data = gson.toJson(result.getData());
//                {"info":"操作成功","status":"ok"}
                //保存成功后，需要把箱子，从原来的分箱单中删掉，目标分箱单增加

                ZBoxEntity.Line line = null;
                //一，删掉源分箱单 箱号
                List<ZBoxEntity.Line> sourceList = fBoxMap.get(sourceBoxNum).getLines();
                for (int i = 0; i < sourceList.size(); i++) {
                    if (fboxLineId.equals(sourceList.get(i).getId())) {
                        line = sourceList.get(i);
                        fBoxMap.get(sourceBoxNum).getLines().remove(i);
                        break;
                    }
                }
                //二，增加目标分箱单 箱号
                fBoxMap.get(targetFboxNum).getLines().add(line);
                collectionIsSave = false;
//                //源分箱单
//                binding.icdCollection.etSourceFboxNum.setText(targetFboxNum);
                adapter.notifyDataSetChanged();
                ToastUtil.showTextShort("保存成功！");
            }

            @Override
            public void onFailure(Exception e) {
                dialogHelper.dismissDialog();
            }
        });
    }


    /**
     * 批量出库&出库确认
     */
    private void BatchOut(ZBoxEntity.Commit commit) {
        Log.i(TAG, "BatchOut: " + gson.toJson(commit));

//        ToastUtil.showTextShort("过账成功！");
//        Main main = (Main) getActivity();
//        main.setFragments(bizType);
        DialogHelper dialogHelper = new DialogHelper(this.getActivity());
        dialogHelper.showLoadingDialog("正在提交");
        OkHttpUtils okHttpUtils = OkHttpUtils.getInstance();
        String url = "";
        if (bizType.equals(CCZT_BizConfig.CKQR)) {
            //出库确认
            url = Urls.URL_FBOX_BATCH_SURE;
            commit.setCommitType("SUBMIT");
            commit.setBizType("OUT_JIAN_HUO");
        } else if (bizType.equals(CCZT_BizConfig.WZCK)) {
            //批量出库
            url = Urls.URL_FBOX_BATCH_OUT;
            commit.setCommitType("SUBMIT");
            commit.setBizType("OUT_CARRY");
        }
        okHttpUtils.doPostJson(url, bo.cookie, gson.toJson(commit), new OkHttpUtils.NetCallBack() {
            @Override
            public void onSuccess(Result result) {
                dialogHelper.dismissDialog();
//                String data = gson.toJson(result.getData());
//                {"info":"操作成功","status":"ok"}
//                数据全部清空，焦点定在台头页面
                ToastUtil.showTextShort("过账成功！");
                Main main = (Main) getActivity();
                main.setFragments(bizType);
            }

            @Override
            public void onFailure(Exception e) {
                dialogHelper.dismissDialog();
            }
        });
    }

}